<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%@ include file="taglibs.jsp"%>
<title>XXXXXX管理平台</title>
<script type="text/javascript">
	$(document).ready(function() {
		$('#loginDiv').window({
			title : "登陆",
			width : 400,
			height : 250,
			collapsible : false,
			minimizable : false,
			maximizable : false,
			closable : false,
			draggable : false,
			resizable : false
		});

		$('#login').click(function() {
			
			$('form').form('submit', {
				url : '${ctx}/login/auth',
				onSubmit : function() {
					//$(this).form('enableValidation');
					return $(this).form('validate');
				},
				success : function(data) {
					var obj = $.parseJSON(data);
					if (obj.success) {
						window.location.href = '${ctx}/index';
					} else {
						$.messager.alert('错误', obj.msg, 'error');
					}
				}
			});
		});
		
		$('#captcha').click(function() {
			$(this).attr('src', '${ctx}/captcha?' + Math.random());
		});
		
		// 加载页面时不验证
		//$('form').form('disableValidation');
		
		$('input[name="loginName"]').focus();
	});
</script>

</head>
<body>
	<div id="loginDiv" style="padding: 20px;">
		<form method="post">
			<div class="divRow">
				<p>账号:</p>
				<span class="divCeil"><input type="text" name="loginName" class="easyui-validatebox" data-options="required:true" /></span>
			</div>
			<div class="divRow">
				<p>密码:</p>
				<span class="divCeil"><input type="password" name="password" class="easyui-validatebox" data-options="required:true" /></span>
			</div>
			<div class="divRow">
				<p>验证码:</p>
				<span class="divCeil"><input type="text" name="code" class="easyui-validatebox" data-options="required:true,validType:'length[4,4]',width:50"  maxlength="4"/></span>
				<img id="captcha" alt="验证码" src="${ctx}/captcha" style="width: 95px;height: 30px" />
			</div>
			<div style="padding: 5px; text-align: center;">
				<a href="javascript:void(0)" id="login" class="easyui-linkbutton" iconCls="icon-ok">登陆</a>
				<a href="javascript:void(0)" id="reset" class="easyui-linkbutton" iconCls="icon-reload">重置</a>
			</div>
		</form>
	</div>
</body>
</html>
